// pages/order/order.js
const app = getApp()
const ApiRootUrl = 'http://8.136.195.245:8000/';
Page({
  /**
   * 页面的初始数据
   */
  data: {
    TabCur: 0,
    scrollLeft:0,
    cardPayList: [{
      id: 0,
      fruitName:"西瓜",
      cardUid:"card1",
      fruitWeight:2,
      unitPrice:2,
      totalPrice:4,
      payState:1,
      gmtCreate:"2021-06-22 16:23:02",
      fruitPicture: 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1070649221,78984387&fm=26&gp=0.jpg'
    },  {
      fruitName:"苹果",
      cardUid:"card1",
      fruitWeight:1,
      unitPrice:2,
      totalPrice:2,
      payState:1,
      gmtCreate:"2021-06-22 16:23:02",
      fruitPicture: 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1070649221,78984387&fm=26&gp=0.jpg'
    }],
    scanPayList: [{
      fruitName:"西瓜",
      userId:"1",
      fruitWeight:2,
      unitPrice:2,
      totalPrice:4,
      payState:1,
      gmtCreate:"2021-06-22 16:23:02",
      fruitPicture: 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1070649221,78984387&fm=26&gp=0.jpg'
    },  {
      fruitName:"苹果",
      userId:"card1",
      fruitWeight:1,
      unitPrice:2,
      totalPrice:2,
      payState:1,
      gmtCreate:"2021-06-22 16:23:02",
      fruitPicture: 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1070649221,78984387&fm=26&gp=0.jpg'
    }],
  },
  tabSelect(e) {
    this.setData({
      TabCur: e.currentTarget.dataset.id,
      scrollLeft: (e.currentTarget.dataset.id-1)*60
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getCardpayRecord()
  },

  getScanpayRecord: function () {
    var that1 =this
    wx.request({
      // url: 'http://8.136.195.245:5006/api/wxlogin/login1', //服务器
      // url:"http://localhost:8001/orders/getOrderByPaystate/"+app.globalData.userId,
      url: ApiRootUrl+"orders/getOrderByPaystate/"+app.globalData.userId,
      // url: "http://8.136.195.245:8000/wechat/wxLogin",

      data: {
        payWay:2
      },
      header: {
        "Content-Type": "application/json"
      },
      method: 'GET',
      dataType: 'json',
      success: function (res) {
        console.log("扫码订单记录res=",res)
        console.log("res.data.data=",res.data.data)
        that1.setData({
          scanPayList:res.data.data
        })
      },
      fail: function (err) {}, //请求失败
      complete: function () {} //请求完成后执行的函数
    })
  },
  getCardpayRecord: function () {
    var that1 =this
    wx.request({
      // url: 'http://8.136.195.245:5006/api/wxlogin/login1', //服务器
      // url:"http://localhost:8001/orders/getOrderByPaystate/"+app.globalData.userId,
      // url: "http://8.136.195.245:8000/wechat/wxLogin",
      url: ApiRootUrl+"orders/getOrderByPaystate/"+app.globalData.userId,

      data: {
        payWay:1
      },
      header: {
        "Content-Type": "application/json"
      },
      method: 'GET',
      dataType: 'json',
      success: function (res) {
        console.log("res=",res)
        console.log("刷卡函数res.data.data",res.data.data)
        that1.setData({
          cardPayList:res.data.data
        })
      },
      fail: function (err) {}, //请求失败
      complete: function () {} //请求完成后执行的函数
    })
  },
})